<?php
// vim: set ts=4 sw=4 sts=4 et:

/**
 * LiteCommerce
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to licensing@litecommerce.com so we can send you a copy immediately.
 *
 * PHP version 5.3.0
 *
 * @category  LiteCommerce
 * @author    Creative Development LLC <info@cdev.ru>
 * @copyright Copyright (c) 2011 Creative Development LLC <info@cdev.ru>. All rights reserved
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      http://www.litecommerce.com/
 * @see       ____file_see____
 * @since     1.0.0
 */

namespace XLite\Model\Base;

/**
 * Object translation
 *
 * @see   ____class_see____
 * @since 1.0.0
 *
 * @MappedSuperclass
 */
abstract class Translation extends \XLite\Model\AEntity
{
    const DEFAULT_LANGUAGE = 'en';

    /**
     * Label unique id
     *
     * @var   integer
     * @see   ____var_see____
     * @since 1.0.0
     *
     * @Id
     * @GeneratedValue (strategy="AUTO")
     * @Column         (type="integer")
     */
    protected $label_id;

    /**
     * Label language code
     *
     * @var   string
     * @see   ____var_see____
     * @since 1.0.0
     *
     * @Column (type="fixedstring", length="2")
     */
    protected $code = self::DEFAULT_LANGUAGE;


    /**
     * Return list of class properties which are not translated
     *
     * @return array
     * @see    ____func_see____
     * @since  1.0.0
     */
    public static function getInternalProperties()
    {
        return array('label_id', 'code');
    }


    /**
     * Return the owner object
     *
     * @return \XLite\Model\AEntity
     * @see    ____func_see____
     * @since  1.0.0
     */
    public function getOwner()
    {
        return $this->owner;
    }

     /**
      * Check cache after enity persist or remove
      *
      * @return void
      * @see    ____func_see____
      * @since  1.0.0
      */
    public function checkCache()
    {
        parent::checkCache();

        // Check translation owner cache
        if ($this->getOwner()) {
            $this->getOwner()->checkCache();
        }
    }
}
